<?php
	/**
	* Product  - Save
	* @author trungdt
	* @since Oct 3, 2011
	* 
	* Change logs
	* 
	*/

	if (!defined('EXPONENT')) exit('');

	$product = null;
	if (isset($_POST['id'])) {
		$product = $db->selectObject('productsmodule_products','id='.intval($_POST['id']));
		if ($product) {
			$loc = unserialize($product->location_data);
		}
	} 

	if (exponent_permissions_check(array('administrate','configure', "create", "edit"),$loc)){
		$product = productsmodule_categories::product_update($_POST,$product, $loc);
		$product->location_data = serialize($loc);

		if (isset($product->id)) {
			$db->updateObject($product,'productsmodule_products');
		} else {
			$db->insertObject($product,'productsmodule_products');
		}
		exponent_flow_redirect();
	} else {
		echo SITE_404_HTML;
	}

?>
